using System;
using Csla;
using Ent.AccesoDatos;
using System.Collections.Generic;

namespace Ent.Inscripcion.Core.Administracion
{
    [Serializable]
    public class Notificacion : BusinessBase<Notificacion>
    {
        #region Business Methods

        // TODO: add your own fields, properties and methods

        // example with private backing field
        private static PropertyInfo<int> IdProperty =
          RegisterProperty(typeof(Notificacion), new PropertyInfo<int>("Id"));
        private int _Id = IdProperty.DefaultValue;
        public int Id
        {
            get { return GetProperty(IdProperty, _Id); }
            set { SetProperty(IdProperty, ref _Id, value); }
        }

        public static readonly PropertyInfo<int> id_notificacionProperty = RegisterProperty<int>(c => c.id_notificacion);
        /// <Summary>
        /// Gets or sets the id_notificacion value.
        /// </Summary>
        public int id_notificacion
        {
            get { return GetProperty(id_notificacionProperty); }
            set { SetProperty(id_notificacionProperty, value); }
        }

        public static readonly PropertyInfo<int> Ofer_horario_idProperty = RegisterProperty<int>(c => c.Ofer_horario_id);
        /// <Summary>
        /// Gets or sets the Ofer_horario_id value.
        /// </Summary>
        public int Ofer_horario_id
        {
            get { return GetProperty(Ofer_horario_idProperty); }
            set { SetProperty(Ofer_horario_idProperty, value); }
        }

        public static readonly PropertyInfo<int> Estudiante_idProperty = RegisterProperty<int>(c => c.Estudiante_id);
        /// <Summary>
        /// Gets or sets the Estudiante_id value.
        /// </Summary>
        public int Estudiante_id
        {
            get { return GetProperty(Estudiante_idProperty); }
            set { SetProperty(Estudiante_idProperty, value); }
        }

        public static readonly PropertyInfo<string> EstadoProperty = RegisterProperty<string>(c => c.Estado);
        /// <Summary>
        /// Gets or sets the Estado value.
        /// </Summary>
        public string Estado
        {
            get { return GetProperty(EstadoProperty); }
            set { SetProperty(EstadoProperty, value); }
        }
        #endregion

        #region Validation Rules

        protected override void AddBusinessRules()
        {
            // TODO: add validation rules
            //ValidationRules.AddRule(RuleMethod, "");
        }

        #endregion

        #region Authorization Rules

        

        private static void AddObjectAuthorizationRules()
        {
            // TODO: add authorization rules
            //AuthorizationRules.AllowEdit(typeof(Notificacion), "Role");
        }

        #endregion

        #region Factory Methods

        public static Notificacion NewEditableRoot()
        {
            return DataPortal.Create<Notificacion>();
        }

        public static Notificacion GetEditableRoot(int id)
        {
            return DataPortal.Fetch<Notificacion>(
              new SingleCriteria<Notificacion, int>(id));
        }

        public static void DeleteEditableRoot(int id)
        {
            DataPortal.Delete<Notificacion>(id);
        }

        private Notificacion()
        { /* Require use of factory methods */ }

        #endregion

        #region Data Access

        [RunLocal]
        protected override void DataPortal_Create()
        {
            // TODO: load default values
            // omit this override if you have no defaults to set
            base.DataPortal_Create();
        }

        private void DataPortal_Fetch(int criteria)
        {
            // TODO: load values
        }

        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Insert()
        {
            var accesoDatos = new DriveDataBase(TypeDataBase.Mysql);
            var parametros = new List<Parametro>
                                 {
                                     new Parametro("i_id_notificacion", ReadProperty(id_notificacionProperty)),
                                     new Parametro("i_id_ofer_horario", ReadProperty(Ofer_horario_idProperty)),
                                     new Parametro("i_id_estudiante", ReadProperty(Estudiante_idProperty)),
                                     new Parametro("s_estado", ReadProperty(EstadoProperty))
                                 };

            accesoDatos.EjecutarQuery("");
        }

        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Update()
        {
            // TODO: update values
        }

        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_DeleteSelf()
        {
            DataPortal_Delete(this.Id);
        }

        [Transactional(TransactionalTypes.TransactionScope)]
        private void DataPortal_Delete(int criteria)
        {
            // TODO: delete values
        }

        #endregion
    }
}
